<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
  />
</template>
<script>
export default {
  data() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'health/diagnosis/physique/phydiagrecorditem',
      // Web路径
      webPath: 'health/diagnosis/physique/PhyDiagRecordItem',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "phyQuestionCode",
              name: "体质问答题编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "phyQuestionName",
              name: "体质问答题名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "phyDiagRecordCode",
              name: "体质诊断记录编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "phyDiagRecordName",
              name: "体质诊断记录名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "phyQuestionCode",
          name: "体质问答题编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "phyQuestionName",
          name: "体质问答题名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "phyDiagRecordCode",
          name: "体质诊断记录编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "phyDiagRecordName",
          name: "体质诊断记录名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "optionKey",
          name: "选项值",
          span: 6,
          type: "select",
          config: {
            edit: false,
            keyField: "key",
            valueField: "value",
            options: [
              { key: "1", value: "选项1" },
              { key: "2", value: "选项2" },
              { key: "3", value: "选项3" },
              { key: "4", value: "选项4" },
              { key: "5", value: "选项5" },
              { key: "6", value: "选项6" },
              { key: "7", value: "选项7" },
              { key: "8", value: "选项8" }
            ]
          }
        },
        {
          code: "optionValue",
          name: "选项内容",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [

        {
          rowIndex: 1,
          items: [
            {
              code: "phyQuestionCode",
              span: 6,
              name: "体质问答题编码",
              type: "popup",
              config: {
                url: "health/diagnosis/physique/phyquestion",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  const formData = {
                    phyQuestionName: row.name,
                    phyQuestionCode: row.code,
                    phyQuestionId: row.id
                  }
                  this.$refs.commonPage.updateFormData(formData)
                }
              }
            },
            {
              code: "phyQuestionName",
              name: "体质问答题名称",
              span: 6,
              type: "text",
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "phyDiagRecordCode",
              span: 6,
              name: "体质诊断记录编码",
              type: "popup",
              config: {
                url: "health/diagnosis/physique/phydiagrecord",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  const formData = {
                    phyDiagRecordName: row.name,
                    phyDiagRecordCode: row.code,
                    phyDiagRecordId: row.id
                  }
                  this.$refs.commonPage.updateFormData(formData)
                }
              }
            },
            {
              code: "phyDiagRecordName",
              name: "体质诊断记录名称",
              span: 6,
              type: "text",
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "optionKey",
              name: "选项值",
              span: 6,
              type: "select",
              config: {
                edit: false,
                keyField: "key",
                valueField: "value",
                options: [
                  { key: "1", value: "选项1" },
                  { key: "2", value: "选项2" },
                  { key: "3", value: "选项3" },
                  { key: "4", value: "选项4" },
                  { key: "5", value: "选项5" },
                  { key: "6", value: "选项6" },
                  { key: "7", value: "选项7" },
                  { key: "8", value: "选项8" }
                ]
              }
            },
            {
              code: "optionValue",
              name: "选项内容",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            }
          ]
        }
      ]
    }
  }
}
</script>
